clear all;
clear java;

% vec_path = 'E:\data\PNNL\smhagos';
% vec_path = 'D:/data/flow_entropy/3D';
% vec_path = 'E:/leeten/project/data/FlowEntropy/3D';
% vec_path = 'D:/projects/data/flow_entropy/2D';
vec_path = 'D:/projects/data/flow_entropy/3D';

    'source', ...
	'sink', ...
	'circle', ...
	'saddle', ...
	'electro', ...
	'equation', ...
	'tornado_swapped', ...
	'wrfout_d01_2007-10-01_18_00_00.t_1.d_1', ...
    ;
    'source.block_graph.block_8_8_8.weight_streamline', ...
    'circle.block_graph.block_8_8_8.weight_streamline', ...
    'saddle.block_graph.block_8_8_8.weight_streamline', ...
    'equation.block_graph.block_8_8_8.weight_streamline', ...
    'tornado_swapped.block_graph.block_8_8_8.weight_streamline', ...
    'wrfout_d01_2007-10-01_18_00_00.t_1.d_1.block_graph.block_30_30_9.weight_streamline', ...
    'wrfout_d01_2007-10-01_18_00_00.t_1.d_1.face_graph.block_30_30_9', ...
    ;
    'circle.block_graph.block_8_8_8.weight_streamline', ...
    'equation.block_graph.block_8_8_8.weight_streamline', ...
    'electro.block_graph.block_8_8_8.weight_streamline', ...

vec_graphs = ...
{
    {'source', 'block_graph.block_8_8_8.weight_streamline'}, ...
};

% graph_names = {...
%     'circle.block_graph.block_8_8_8.weight_streamline', ...
%     'source.block_graph.block_8_8_8.weight_streamline', ...
%     };

n_vec_graphs = length(vec_graphs);

ns_parts = 2.^(4);

%% specify the clustering algorithm
mapping_algorithm = 'spectral_clustering';
% mapping_algorithm = 'diffusion_map';

switch mapping_algorithm
    case 'diffusion_map'
        %% parameters for diffusion map
        cluster_dist = 'single';

        %% clustering methods for diffusion map
        % clustering_method = 'kmeans';
        clustering_method = 'recursive_hierarchical_even';
        % clustering_method = 'hierarchical_even';
        % clustering_method = 'hierarchical';
end

%% scan all vector fields
for vgi = 1:n_vec_graphs
    vec_name = vec_graphs{vgi}{1};
    graph_name = [vec_name '.' vec_graphs{vgi}{2}];
    
    for manual_n_parts = ns_parts
        %% decide the default #rows to show the clusters
        default_n_rows = ceil(sqrt(manual_n_parts));
    
        script_partition_graph;
    end
end

